#! /bin/sh
# Run GBmod with Xwindow Graphics
#------------------------------------------------
set -x

binfile=model.bin

unidata=uni.bin
normray=1
normface=40
surface=0
nrays=100

##### Built syncline model (Figure 14)

trimodel xmin=0 zmin=0 xmax=25 zmax=12 maxangle=10 \
	normray=$normray normface=$normface nrays=$nrays \
1	xedge=0,25 \
	zedge=0,0 \
	sedge=0,0 \
2       xedge=0,0.3632,1.1131,1.802,2.6474 \
        zedge=2.567,2.605,2.671,2.706,2.7247  \
        sedge=0,0,0,0,0 \
3       xedge=2.6474,3.63,4.629,5.543,6.465,6.884 \
        zedge=2.7247,2.739,2.726,2.686,2.617,2.579  \
        sedge=0,0,0,0,0,0 \
4       xedge=6.884,7.756,8.346,9.038,9.656,10.001 \
        zedge=2.579,2.474,2.364,2.208,2.044,1.936  \
        sedge=0,0,0,0,0,0 \
5       xedge=10.001,10.409,10.550,10.796,11.069,11.383 \
        zedge=1.936,1.7902,1.7323,1.6196,1.4911,1.3648  \
        sedge=0,0,0,0,0,0 \
6       xedge=11.383,11.749,12.104,12.251,12.408,12.579 \
        zedge=1.3648,1.266,1.220,1.214,1.218,1.235  \
        sedge=0,0,0,0,0,0 \
7       xedge=12.579,12.945,13.278,13.618,13.906,14.185 \
        zedge=1.235,1.326,1.474,1.675,1.867,2.061  \
        sedge=0,0,0,0,0,0 \
8       xedge=14.185,14.499,14.890,15.174,15.430,15.584 \
        zedge=2.061,2.273,2.514,2.670,2.788,2.845  \
        sedge=0,0,0,0,0,0 \
9       xedge=15.584,15.846,16.513,17.200,17.9330,18.492 \
        zedge=2.845,2.918,3.015,3.079,3.119,3.114  \
        sedge=0,0,0,0,0,0 \
10      xedge=18.492,19.135,19.741,20.391,20.929,21.650 \
        zedge=3.114,3.089,3.068,3.036,2.987,2.890  \
        sedge=0,0,0,0,0,0 \
11      xedge=21.650,22.221,22.76,23.441,23.811,25.00 \
        zedge=2.890,2.823,2.767,2.688,2.649,2.638  \
        sedge=0,0,0,0,0,0 \
12      xedge=0,0.246,1.121,1.931,2.916 \
        zedge=4.487,4.491,4.488,4.459,4.416  \
        sedge=0,0,0,0,0 \
13      xedge=2.916,3.695,4.404,5.106,5.703,6.306 \
        zedge=4.416,4.363,4.295,4.216,4.125,4.012  \
        sedge=0,0,0,0,0,0 \
14      xedge=6.306,7.233,7.967,8.613,9.113,9.753 \
        zedge=4.012,3.781,3.562,3.321,3.030,2.520  \
        sedge=0,0,0,0,0,0 \
15      xedge=9.753,10.281,10.476,10.705,10.911,11.224 \
        zedge=2.520,2.064,1.904,1.7319,1.598,1.4392  \
        sedge=0,0,0,0,0,0 \
16      xedge=11.224,11.573,11.9099,12.2515,12.5796,12.9453 \
        zedge=1.4392,1.3257,1.2664,1.2474,1.2704,1.3611  \
        sedge=0,0,0,0,0,0 \
17      xedge=12.9453,13.2789,13.6183,13.9061,14.1852,14.4999 \
        zedge=1.3611,1.507,1.7058,1.8973,2.0899,2.2999  \
        sedge=0,0,0,0,0,0 \
18      xedge=14.4999,14.8902,15.2933,15.5841,16.2234,16.8691 \
        zedge=2.2999,2.5396,2.7622,2.9046,3.1667,3.3966  \
        sedge=0,0,0,0,0,0 \
19      xedge=16.8691,17.4111,17.9351,18.4711,19.0181,19.6179 \
        zedge=3.3966,3.5594,3.6871,3.7896,3.8828,3.9555 \
        sedge=0,0,0,0,0,0 \
20      xedge=19.6179,20.2965,20.9890,21.5864,22.3440,22.9247 \
        zedge=3.9555,4.0062,4.0514,4.0681,4.0659,4.070 \
        sedge=0,0,0,0,0,0 \
21      xedge=22.9247,23.441,23.8471,25.0000 \
        zedge=4.070,4.0730,4.0775,4.0901 \
        sedge=0,0,0,0 \
22      xedge=0,0.3441,0.6978,1.1693,1.6042 \
        zedge=6.6253,6.5912,6.5502,6.5083,6.4731 \
        sedge=0,0,0,0,0 \
23      xedge=1.6042,2.0224,2.5229,3.1680,3.930,4.6594 \
        zedge=6.4731,6.4344,6.3747,6.3022,6.2331,6.1730 \
        sedge=0,0,0,0,0,0 \
24      xedge=4.6594,5.4412,6.2075,6.8446,7.5242,7.8241 \
        zedge=6.1730,6.100,6.0416,5.9483,5.8099,5.7393 \
        sedge=0,0,0,0,0,0 \
25      xedge=7.8241,8.3855,9.0078,9.7892,10.4596,10.9628 \
        zedge=5.7393,5.6008,5.4522,5.2721,5.1488,5.0638 \
        sedge=0,0,0,0,0,0 \
26      xedge=10.9628,11.5303,11.8633,12.3610,12.5553,12.8064 \
        zedge=5.0638,4.9739,4.9155,4.8357,4.8129,4.8006 \
        sedge=0,0,0,0,0,0 \
27      xedge=12.8064,13.0573,13.2477,13.4891,13.9302,14.1647 \
        zedge=4.8006,4.8316,4.9092,5.0963,5.6221,5.8549 \
        sedge=0,0,0,0,0,0 \
28      xedge=14.1647,15.2772,16.4715,17.5292,18.5161,19.5567 \
        zedge=5.8549,6.0252,6.0171,6.0560,6.0862,6.1152 \
        sedge=0,0,0,0,0,0 \
29      xedge=19.5567,20.4797,21.4619,21.9887,22.5920,23.2955 \
        zedge=6.1152,6.1365,6.1368,6.1356,6.1233,6.1089 \
        sedge=0,0,0,0,0,0 \
30      xedge=23.2955,23.7952,25.0000 \
        zedge=6.1089,6.1081,6.1199 \
        sedge=0,0,0 \
31      xedge=0,0.6510,1.3203,2.2237,3.0101 \
        zedge=9.4466,9.3076,9.1827,9.0259,8.8606 \
        sedge=0,0,0,0,0 \
32      xedge=3.0101,3.8590,4.0942,4.3736,4.6755,4.8620 \
        zedge=8.8606,8.6643,8.6608,8.7382,8.9115,9.0210 \
        sedge=0,0,0,0,0,0 \
33      xedge=4.8620,5.2040,5.9183,6.5414,7.2326,7.6474 \
        zedge=9.0210,9.1497,9.1082,8.9567,8.7875,8.8229 \
        sedge=0,0,0,0,0,0 \
34      xedge=7.6474,7.9591,8.3100,8.5996,9.0987,9.6972 \
        zedge=8.8229,8.9707,9.1493,9.2107,9.1502,8.9747 \
        sedge=0,0,0,0,0,0 \
35      xedge=9.6972,10.2486,10.7232,11.0516,11.4780,11.6792 \
        zedge=8.9747,8.7928,8.7008,8.7703,9.0566,9.1836 \
        sedge=0,0,0,0,0,0 \
36      xedge=11.6792,12.2261,12.7417,12.9510,13.3296,13.8492 \
        zedge=9.1836,9.2924,9.1777,9.1092,8.9687,8.7616 \
        sedge=0,0,0,0,0,0 \
37      xedge=13.8492,14.3349,14.5957,14.9269,15.1954,15.6440 \
        zedge=8.7616,8.6860,8.7675,8.9594,9.0834,9.1028 \
        sedge=0,0,0,0,0,0 \
38      xedge=15.6440,15.8757,16.4171,16.8555,17.3397,17.6233 \
        zedge=9.1028,9.0463,8.8615,8.7113,8.6206,8.6805 \
        sedge=0,0,0,0,0,0 \
39      xedge=17.6233,17.9012,18.1638,18.5009,19.2401,20.1052 \
        zedge=8.6805,8.8423,9.0156,9.1470,9.0681,8.8475 \
        sedge=0,0,0,0,0,0 \
40      xedge=20.1052,21.1297,22.1653,23.0058,23.5744,25.000 \
        zedge=8.8475,8.5981,8.3820,8.2317,8.1072,8.0362 \
        sedge=0,0,0,0,0,0 \
41      xedge=0,23.844,25 \
	zedge=11.266,11.314,11.320 \
	sedge=0,0,0 \
42	xedge=0,25 \
	zedge=12.0,12.0 \
	sedge=0,0. \
	kedge=1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,7 \
	sfill=1,1,0,0,0.007243,0,0  \
	sfill=1,3,0,0,0.0040312421,0,0  \
	sfill=5,5,0,0,0.0019912,0,0  \
	sfill=5,8,0,0,0.0040312421,0,0  \
	sfill=5,10,0,0,0.0025251888,0,0  \
	sfill=5,11.8,0,0,0.001111111,0,0  \
	>$binfile


spsplot <$binfile -geom 650x300+670+0 \
        labelz="Depth (kft)" labelx="Distance (kft)" \
        labelfont=Helvetica titlefont=Helvetica \
        titlesize=30 title=""\
        dxnum=5 dznum=4 \
        gtri=1  gmin=0.5 gmax=0.9 \
        hbox=4 wbox=6 \
        tricolor= yellow > model.eps

modelfile=model.bin
modelpsfile=model.eps
rayendsfile=nrayend.bin
rayfile=nray.bin
raypsfile=nray.$normface.eps

nonsurface=1 nangle=1 nxz=201
caustic=0  dangle=0 
xs1=8.8 zs1=11.266
ashift=0

normray < $modelfile > $rayendsfile \
	rayfile=$rayfile \
	nangle=$nangle \
	dangle=$dangle \
	nonsurface=$nonsurface \
	xs1=$xs1 zs1=$zs1 \
	caustic=$caustic \
	surface=$surface \
	ashift=$ashift \
	nrays=$nrays nxz=$nxz 

####   plot the rays with CWP graphics
psgraph <$rayfile >$raypsfile \
        nplot=`cat outpar` n=$nxz hbox=4.0 wbox=6.0  \
        d2num=2 x1beg=0 x1end=12 x2beg=0 x2end=25 \
        title=" " d1num=4 d2num=5 \
        style=seismic linegray=0

#####  display the rays and the model
psmerge in=$modelpsfile in=$raypsfile > NShoot.eps


echo
echo "The output are the PostScipt files:"
echo "        model.eps NShoot.eps nray.$normface.eps"
echo
echo "You may preview these files with your PostScript Previewer."
echo
